﻿using System;
using BLToolkit.Data;
using BLToolkit.Data.DataProvider;

namespace PMIS.BLL.System
{
	/// <summary>
	/// 数据库连接管理
	/// </summary>
	public class BL_DatabaseConnection
	{
		/// <summary>
		/// 创建数据库连接
		/// </summary>
		/// <returns></returns>
		public static DbManager CreateConnection()
		{
			//	获取SQLite数据文件路径
			string strSQLitePath = BL_Registry.GetInstance().GetValue("SQLitePath");
			if (string.IsNullOrEmpty(strSQLitePath))
				throw new Exception("无法获取SQLite数据文件路径!");

			//string strConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Persist Security Info=False", strAccessPath);

			//	默认选取Web.config或者app.config中的连接串一节的配置
			return new DbManager(new SQLiteDataProvider(), string.Format("Data Source={0};Version=3;", strSQLitePath));
		}
	}
}
